Skip to content

Fix out-of-range group window shortcuts - #8411

Open
wxasacoder wants to merge 8 commits into
omacom:quattrofrom
wxasacoder:codex/fix-group-window-index
Open

wxasacoder wants to merge 8 commits into
omacom:quattrofrom
wxasacoder:codex/fix-group-window-index

Conversation

@wxasacoder

@wxasacoder wxasacoder commented Aug 26, 2026 •

Copy link
Copy Markdown

Problem

Omarchy binds Super + Alt + 1 through Super + Alt + 5 directly to hl.dsp.group.active.

When the active group contains fewer windows than the selected index, Hyprland returns an Index out of range Lua runtime error. For example, with two windows in a group, Super + Alt + 1 and Super + Alt + 2 work, but pressing Super + Alt + 3 produces an error notification. Repeated key presses can fill the screen with these notifications.
screenshot-2026-08-26_22-39-18

Solution

Resolve the active window and its group when the shortcut is pressed, then dispatch the group switch only when the requested index is within group.size.

Valid group window shortcuts retain their existing behavior. Shortcuts targeting unavailable group positions, or used outside a window group, now safely do nothing.

This uses Hyprland's Lua window and group APIs directly instead of catching or matching runtime error messages.

Testing

  • Added a regression test covering valid, out-of-range, and ungrouped window shortcuts.
  • Ran bash test/shell.d/hyprland-group-bindings-test.sh.
  • Ran bash test/shell.d/hyprland-binding-conflicts-test.sh.

Fixes #12085

Copilot AI balanced review requested due to automatic review settings August 26, 2026 15:35
@wxasacoder

Copy link
Copy Markdown
Author

Testing

Added regression coverage for:

  • Switching to a valid group window
  • Requesting an index greater than the group size
  • Using the shortcut when the active window is not grouped

Focused tests:

  • bash test/shell.d/hyprland-group-bindings-test.sh
  • bash test/shell.d/hyprland-binding-conflicts-test.sh

Manual verification

Tested in a live Omarchy session with two grouped windows:

  • Super + Alt + 1 and Super + Alt + 2 still switch between the grouped windows normally.
  • Super + Alt + 3, Super + Alt + 4, and Super + Alt + 5 are ignored without producing Lua runtime errors.
screenrecording-2026-08-26_23-51-11.mp4

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread test/shell.d/hyprland-group-bindings-test.sh
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@omarchybot omarchybot added the bug Something isn't working label Sep 27, 2026
Lua 5.5 exits 0 when a script it reads from a pipe errors, so `lua <<'LUA'` swallowed every failed assertion and the test passed with the fix reverted. `lua -` reads the same heredoc and exits 1 on an error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed and tested on a disposable Omarchy VM (Hyprland 0.56.2) by Claude Opus 5.5. The fix works: with a two-window group, real Super+Alt+3 and Super+Alt+5 key presses show Runtime error in lua: Index out of range on current quattro, show nothing on this branch, and show it again with the tiling.lua change reverted. Super+Alt+1 and 2 still switch between the grouped windows, so building the dispatcher once and re-dispatching it on each press holds up.

I pushed one commit to your branch, b203ddc. The new test could not fail: on Lua 5.5, lua <<'LUA' exits 0 when the script errors, so it passed with the fix reverted even though its assertions failed. It now runs lua - <<'LUA', which exits 1 on an error. It fails on quattro, fails when only the group.size check is removed, and passes here. ./test/cli and ./test/shell fail the same 62 checks on this branch as on quattro, mostly because node is missing on the test VM, so nothing new breaks.

This fixes #12085. #10693 makes the same change later without a test, and #12155 includes it among five unrelated fixes. This one is the one to take forward.

One side effect, found by reading the code rather than running it: as Lua functions, these five binds can no longer be run from the keybindings menu (omarchy-menu-keybindings finds no dispatcher for them). That already happens with the clipboard binds, and pressing the keys works as before.

No second opinion ran. Codex Medium, the configured reviewer, answered a ping but refused the review because today's review budget is used up. For the same reason the classification at the new head could not be confirmed, so the verified label and the link to #12085 wait for the next pass. Nothing is waiting on you.

@omarchybot omarchybot removed the bug Something isn't working label Sep 28, 2026
merkhanov added a commit to merkhanov/omarchy that referenced this pull request Oct 14, 2026
The pcall guard this branch added made the binds Lua functions, and the
keybindings menu's scanner records a dispatcher only for an
__omarchy_dispatcher table, a string, or an o.bind_commands lookup
(bin/omarchy-menu-keybindings). A function matched none of those, so the
cached dispatcher came back empty, overwrote the __lua one that
`hyprctl binds` reports, and dispatch_binding returned 1. Picking
"Switch to group window 2" from the menu did nothing even when the group
had a second window.

The pcall was also the wrong guard. Hyprland reports the rejection
through its dispatcher result rather than by raising a Lua error, so it
would still have notified.

Check the focused window's group size before dispatching, so nothing is
dispatched past the end of the group and Hyprland has nothing to reject,
and register the equivalent command in o.bind_commands so the menu can
still run the bind. Same approach as omacom#15100. The window.group.size shape
is the one omarchybot verified on a Hyprland 0.56.2 VM against omacom#8411.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@wxasacoder

Copy link
Copy Markdown
Author

Hi @ryanrhughes, thanks for taking a look at this PR!

I noticed that #15100 addresses the same issue and also includes a fix for compatibility with the Super+K shortcut menu.

I'm happy to update this PR to cover that case as well. Would you prefer that I continue improving this PR, or should we move forward with #15100 instead?

Thanks!

@omarchybot omarchybot added the bug Something isn't working label Oct 17, 2026
omarchybot and others added 2 commits October 17, 2026 04:25
As Lua functions, Super+Alt+1 to 5 gave the keybindings menu nothing it could run. The check moves into o.switch_group_window, and each bind registers `hyprctl eval 'o.switch_group_window(n)'` in o.bind_commands, the way o.launch_terminal does, so the entries stay runnable from Super+K.

Co-Authored-By: Omarchybot <317366263+omarchybot@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Oct 17, 2026
@greptile-apps

greptile-apps Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Guards numbered group shortcuts so unavailable positions do nothing.

  • Group number shortcuts only switch to windows that exist.

No new actionable issues found. Tests were inspected, not run.

Reviews (3) · Last reviewed commit: "Stub o.workspaces in the group binding t..." · Reviewed by Greptile

Comment thread test/shell.d/hyprland-group-bindings-test.sh
@omarchybot omarchybot added the ready Good to merge label Oct 17, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

@wxasacoder, thanks for asking about #15100. You don't need to do anything: its one addition, keeping these binds runnable from the Super+K keybindings menu, is now on this branch, so this pull request covers both. It was first to the fix, and it carries the fix forward. #15100 is omabot's own pull request, so you keep the credit for this one.

Two commits went onto your branch. 0c5809e merges current quattro, because the menu mechanism (o.bind_commands) landed after your branch point. 2f0db30 moves the size check into o.switch_group_window(index) and registers hyprctl eval 'o.switch_group_window(n)' for each bind, the same way o.launch_terminal does. The test now also checks that command.

Tested on a disposable Omarchy VM (Hyprland 0.56.2), with Hyprland loading this branch's config and keys pressed through a virtual keyboard:

  • With quattro's tiling.lua, which is this branch with the fix reverted, Super+Alt+3 on a two-window group shows Runtime error in lua: ?:?: Index out of range. On this branch, Super+Alt+3, 4 and 5 show nothing, and Super+Alt+1 and 2 still switch between the two windows.
  • Picking "Switch to group window 2" in the keybindings menu runs hyprctl eval 'o.switch_group_window(2)' and switches the window. All five entries are listed.
  • test/shell.d/hyprland-group-bindings-test.sh passes here and fails with quattro's tiling.lua. ./test/cli passes. ./test/shell fails the same tests on this branch as on quattro, nearly all because node is missing on the VM, so nothing new breaks.

Codex Medium reviewed the change and found no defects, checking the index <= group.size bound against Hyprland 0.56.2's source. It read the same diff after me, so treat that as agreement rather than an independent result. Greptile notes that the test covers "no focused window" but not "a focused window outside a group". That's true, but the code handles both, so no user would see a difference.

This links #12085, which it fixes. #12155 includes the same change among other fixes. It's waiting on the maintainer now.

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@omarchybot omarchybot removed the ready Good to merge label Oct 19, 2026
@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Oct 19, 2026
omarchybot and others added 2 commits October 21, 2026 13:36
Current quattro builds tiling.lua's workspace binds from o.workspaces, which monitor-workspaces.lua defines and this test never loads, so once merged the test died at tiling.lua:25 before reaching a group bind.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Oct 21, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

@wxasacoder, thanks for adding the ungrouped-window case from Greptile's suggestion. It holds: active_window = {} is the one case that would catch the window.group check going missing.

quattro has moved on since the last merge here, and that broke the test, not the fix. tiling.lua now builds the Super+number workspace binds from o.workspaces, which default/hypr/monitor-workspaces.lua defines and this test never loads. Once merged, the test died at tiling.lua:25 with attempt to index a nil value (field 'workspaces') before it reached a group bind. I pushed two commits to your branch: 4d23434 merges current quattro, and 4d565f7 stubs o.workspaces in the test. The fix itself is unchanged.

Tested on a disposable Omarchy VM, with Hyprland loading this branch and keys pressed through a virtual keyboard:

  • With quattro's tiling.lua, which is this branch with the fix reverted, Super+Alt+3 on a two-window group shows Runtime error in lua: ?:?: Index out of range. On this branch, Super+Alt+3 and 5 show nothing, and Super+Alt+1 and 2 still switch between the two windows.
  • The keybindings menu lists all five entries, and its command for group window 1 switches the window.
  • test/shell.d/hyprland-group-bindings-test.sh passes here and fails with quattro's tiling.lua, with only the size check removed, and with only the group check removed. ./test/cli passes, and so do the binding-conflicts, default-config, monitor-workspaces, keybindings-menu, menu-keybindings-key-names and JIS binding tests.

Codex Medium reviewed the merged branch and found no defects. It confirmed that the stub only lets tiling.lua load and that the menu reads o.bind_commands before the newer o.bind_expressions. It saw my results before it reviewed, so take that as agreement, not an independent check.

This fixes #12085. #12155 bundles the same change with unrelated fixes, and #15100 is now covered here. GitHub is holding this branch's CI until a maintainer approves the workflow run. After that, it waits on the maintainer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Super+Alt+number shows an error for unavailable group windows

3 participants